<template>
  <el-table
    :data="deviceList"
    border
    stripe
    style="width: 100%">
    <el-table-column
      prop="ID"
      label="设备序列号"
      width="180">
    </el-table-column>
    <el-table-column
      prop="Name"
      label="名称"
      width="180">
    </el-table-column>
    <el-table-column
      prop="Status"
      label="在线状态"
      :formatter="formatter">
    </el-table-column>
    <el-table-column
      prop="UpdatedAt"
      label="离线时长">
    </el-table-column>
  </el-table>
</template>

<script>
export default {
  name: 'device',
  components: {},
  data () {
    return {
      cameraId: '34020000001110000851',
      deviceList: []
    }
  },
  created () {
    this.getDeviceList()
  },
  methods: {
    // 视频回放
    getDeviceList () {
      this.$axios.get('/api/v1/device/info', {
        params: {
          serial: this.cameraId
        }
      })
        .then(response => {
          this.deviceList = response.ChannelList
        })
    },
    formatter (row, column) {
      return row.Status === 'ON' ? '在线' : '离线'
    }
  }
}
</script>
